<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
  <head>
    <title>Mapping a URL to a form
</title>
  </head>

  <body>
    <p>In application mode forms are usually shown using the Show method, just as in a desktop application. However sometimes you may wish to link to a form from an external site, IPM, or make the form bookmarkable. This can be done by mapping a URL to the form.
</p>
    <p>In previous versions of IntraWeb the only way to map a URL to a form was to pass a parameter to the start URL. This is similar to passing command line parameters to an application. This sufficed in many circumstances, but of course users still requested the ability to map a real URL to a form, as well as the ability to bookmark forms.</p>
    <p>XI allows this. While it seems simple and many expected this should have been added a long time ago, it is anything but simple.</p>
    <h3>Mapping a URL</h3>
    <p>First, add IWURLMap to the uses clause. Then a form can be mapped to a URL:</p>
    <p style="MARGIN-LEFT: 40px">initialization<br>&nbsp; TIWURLMap.Add('/red/', 'index.html', TfrmRed);
      <br>end.
      <br>
    </p>
    <p>The arguments for Add in order are:</p>
    <ul>
      <li>Path</li>
      <li>File</li>
      <li>Class of the form.</li>
    </ul>
    <p>In this example, this form will respond to /red/index.html, or simply /red/. If file is an empty string, it will respond to /red/*. Any document will match. For more information, see <a href="../Classes/URLResponders/">URL Responders</a> as they use the same registration routines.
    </p>
    <h3>Sessions</h3>
    <p>If a session is found, the existing session will be used for the form. If no session is found, a new one will be created. Thus, URL mapped forms can serve as start URLs. To allow bookmarking, the URL will remain in the browser, even if a new session is created. </p>
    <h3>Form Stack<br>
    </h3>
    <p>A new instance of the form will be created, and shown. This will cause it to be the new active form and on top of the form stack.</p>
    <p>If the user continually refreshes the URL, or clicks a lot of links mapped to forms, this can cause form instances to pile up on the stack. If this is a concern, you may wish to monitor or occasionally prune duplicate or old form instances from the user's form stack.<br>
    </p>
    <p>Because the form stack is used, it is also important that mapped URLs are no used for new windows. If this occurs, the first window will be out of sync with the form stack and the user will receive an error when submitting that form. In future versions of IntraWeb we plan to add options for handling multiple windows concurrently.</p>
    <p></p>

  </body>
</html>
